<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class giaovienvaitro_db 
	{
		public function Them($MaVaiTro, $TenVaiTro)
		{
			$sql = "INSERT INTO `tbl_giaovienvaitro`(`MaVaiTro`, `TenVaiTro`)
					VALUES ('$MaVaiTro', '$TenVaiTro')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaVaiTro)
		{
			$sql = "DELETE FROM `tbl_giaovienvaitro` WHERE `MaVaiTro` = '$MaVaiTro'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaVaiTro, $TenVaiTro)
		{
			$sql = "UPDATE `tbl_giaovienvaitro`
					SET `TenVaiTro` = '$TenVaiTro'
					WHERE `MaVaiTro` = '$MaVaiTro'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaVaiTro, $TenVaiTro)
		{
			$sql = "SELECT * FROM `tbl_giaovienvaitro` WHERE 1  ";
			if($MaVaiTro != "")
				$sql .= " AND `MaVaiTro` = '$MaVaiTro' ";

			if($TenVaiTro != "")
				$sql .= " AND `TenVaiTro` = '$TenVaiTro' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

